/**
 * Enhanced Search Styles
 * Aligned with NVIDIA Sphinx theme - full light/dark mode support
 * Uses theme variables exclusively - no hardcoded colors
 */

/* CSS Variables for theming */
:root {
    --search-primary-color: var(--nv-color-green, #76b900);
    --search-background: var(--pst-color-background, #ffffff);
    --search-surface: var(--pst-color-surface, #f8f9fa);
    --search-text-primary: var(--pst-color-text-base, #333333);
    --search-text-secondary: var(--pst-color-text-muted, #6c757d);
    --search-border: var(--pst-color-border, #e1e4e8);
    --search-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --search-font-family: var(--pst-font-family-base, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif);
}

/* ===== SEARCH PAGE STYLES ===== */

/* Unified Search Controls Container */
.search-controls-container {
    background-color: var(--pst-color-background);
    border: 1px solid var(--pst-color-on-surface);
    border-radius: 0.5rem;
    padding: 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Search Filters */
.search-filters {
    margin-bottom: 1rem;
}

.filter-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(160px, 1fr)) auto;
    gap: 1rem;
    align-items: center;
}

.filter-actions {
    justify-self: end;
}

.filter-group {
    min-width: 160px;
}

/* Enhanced responsive layout for 3 main filters */
@media (max-width: 900px) {
    .filter-row {
        grid-template-columns: repeat(2, minmax(160px, 1fr));
        gap: 0.75rem;
    }
    
    .filter-actions {
        grid-column: span 2;
        justify-self: center;
        margin-top: 0.5rem;
    }
}

.filter-select {
    width: 100%;
    max-width: 220px;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    font-family: var(--pst-font-family-base);
    color: var(--pst-color-text-base);
    background-color: var(--pst-color-background);
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 16px 12px;
    border: 1px solid var(--pst-color-on-surface);
    border-radius: 0.25rem;
    outline: none;
    appearance: none;
    cursor: pointer;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    text-overflow: ellipsis;
}

.filter-select:focus {
    border-color: var(--nv-color-green);
    box-shadow: 0 0 0 0.2rem rgba(118, 185, 0, 0.25);
}

.filter-select:hover {
    border-color: var(--pst-color-text-muted);
}

.filter-select option {
    background-color: var(--pst-color-background);
    color: var(--pst-color-text-base);
}

.filter-select option:hover,
.filter-select option:focus {
    background-color: var(--pst-color-on-surface);
    color: var(--pst-color-text-base);
}

.filter-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: var(--pst-font-family-base);
    text-decoration: none;
    border-radius: 0.25rem;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-secondary {
    color: var(--pst-color-text-base);
    background-color: transparent;
    border-color: var(--pst-color-on-surface);
}

.btn-secondary:hover {
    color: var(--pst-color-background);
    background-color: var(--pst-color-text-base);
    border-color: var(--pst-color-text-base);
}

.btn-secondary:focus {
    color: var(--pst-color-text-base);
    background-color: transparent;
    border-color: var(--nv-color-green);
    box-shadow: 0 0 0 0.2rem rgba(118, 185, 0, 0.25);
}

.btn-outline-secondary {
    color: var(--pst-color-text-base);
    background-color: transparent;
    border-color: var(--pst-color-on-surface);
}

.btn-outline-secondary:hover {
    color: var(--pst-color-background);
    background-color: var(--pst-color-text-base);
    border-color: var(--pst-color-text-base);
}

/* Responsive filters */
@media (max-width: 768px) {
    .search-controls-container {
        padding: 0.75rem;
    }
    
    .search-filters {
        margin-bottom: 0.75rem;
    }
    
    .filter-row {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .filter-group {
        min-width: auto;
    }
    
    .filter-actions {
        grid-column: 1;
        justify-self: center;
        margin-top: 0.75rem;
    }
}

#enhanced-search-page-input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: var(--pst-font-family-base);
    font-weight: 400;
    line-height: 1.5;
    color: var(--pst-color-text-base);
    background-color: var(--pst-color-background);
    border: 1px solid var(--pst-color-on-surface);
    border-radius: 0.25rem;
    outline: none;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.search-input-unified {
    margin-top: 0 !important;
}

#enhanced-search-page-input:focus {
    border-color: var(--nv-color-green);
    box-shadow: 0 0 0 0.2rem rgba(118, 185, 0, 0.25);
}

#enhanced-search-page-input::placeholder {
    color: var(--pst-color-text-muted);
    opacity: 1;
}

.loading {
    display: inline-block;
    margin-left: 0.5rem;
    color: var(--pst-color-text-muted);
}

.spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 0.125rem solid var(--pst-color-text-muted);
    border-radius: 50%;
    border-top-color: var(--nv-color-green);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#search-results {
    margin-top: 1.5rem;
}

/* ===== SEARCH RESULTS STYLES ===== */

.search-results-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--pst-color-on-surface);
}

.search-results-header h3 {
    color: var(--pst-color-heading);
    font-family: var(--pst-font-family-heading);
    font-weight: var(--pst-font-weight-heading);
    font-size: var(--pst-font-size-h3);
    margin: 0 0 0.5rem 0;
}

.search-results-header p {
    color: var(--pst-color-text-muted);
    font-size: 0.875rem;
    margin: 0;
}

/* Search Result Cards */
.search-result {
    background-color: var(--pst-color-background);
    border: 1px solid var(--pst-color-on-surface);
    border-radius: 0.5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    transition: all 0.2s ease-in-out;
    position: relative;
    overflow: hidden;
}

.search-result::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--nv-color-green), var(--nv-color-green-2));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.2s ease-in-out;
}

.search-result:hover {
    border-color: var(--nv-color-green);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.1);
    transform: translateY(-0.125rem);
}

.search-result:hover::before {
    transform: scaleX(1);
}

/* Result Header */
.result-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.section-icon {
    flex-shrink: 0;
    width: 3rem;
    height: 3rem;
    border-radius: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--pst-color-background);
    background: var(--nv-color-green);
    border: 1px solid var(--pst-color-on-surface);
}

.result-info {
    flex-grow: 1;
    min-width: 0;
}

.result-title {
    margin: 0 0 0.5rem 0;
    font-family: var(--pst-font-family-heading);
    font-weight: var(--pst-font-weight-heading);
    font-size: var(--pst-font-size-h4);
    line-height: 1.25;
}

.result-title a {
    color: var(--pst-color-heading);
    text-decoration: none;
    transition: color 0.15s ease-in-out;
}

.result-title a:hover {
    color: var(--nv-color-green);
    text-decoration: underline;
    text-decoration-color: var(--nv-color-green);
    text-decoration-thickness: max(3px, 0.1875rem, 0.12em);
}

/* Breadcrumb */
.result-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--pst-color-text-muted);
    margin-bottom: 0.5rem;
    font-family: var(--pst-font-family-base);
}

.result-breadcrumb .breadcrumb-separator {
    color: var(--pst-color-text-muted);
    font-weight: 400;
}

/* Meta Information */
.result-meta {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.section-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background-color: var(--pst-color-background);
    border: 1px solid var(--pst-color-on-surface);
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--pst-color-text-base);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.relevance-score {
    font-size: 0.75rem;
    color: var(--pst-color-text-muted);
    font-weight: 500;
    font-family: var(--pst-font-family-monospace);
}

/* Result Content */
.result-content {
    color: var(--pst-color-text-base);
    font-family: var(--pst-font-family-base);
    line-height: 1.6;
    margin-bottom: 1rem;
}

.result-content p {
    margin: 0 0 0.75rem 0;
}

.result-content p:last-child {
    margin-bottom: 0;
}

.result-summary {
    color: var(--pst-color-text-base);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

/* Matching Sections */
.matching-sections {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--pst-color-on-surface);
}

.matching-sections h4,
.matching-sections h5 {
    color: var(--pst-color-heading);
    font-family: var(--pst-font-family-heading);
    font-weight: 500;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 0.75rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-links {
    background-color: var(--pst-color-background);
    border: 1px solid var(--pst-color-on-surface);
    border-radius: 0.5rem;
    padding: 0.75rem;
}

.section-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    color: var(--pst-color-text-base);
    text-decoration: none;
    transition: all 0.15s ease-in-out;
    font-family: var(--pst-font-family-base);
    margin-bottom: 0.25rem;
}

.section-link:last-child {
    margin-bottom: 0;
}

.section-link:hover {
    background-color: var(--nv-color-green);
    color: var(--pst-color-background);
    text-decoration: none;
    transform: translateY(-0.0625rem);
    box-shadow: 0 0.25rem 0.5rem rgba(118, 185, 0, 0.25);
}

.section-link .section-icon {
    width: 1.5rem;
    height: 1.5rem;
    font-size: 0.875rem;
    background: var(--pst-color-surface);
    color: var(--pst-color-primary);
}

.section-link:hover .section-icon {
    background: var(--pst-color-background);
    color: var(--nv-color-green);
}

/* Enhanced Result Features */
.result-tag, .result-category {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.25rem;
    text-decoration: none;
    margin-right: 0.25rem;
    margin-bottom: 0.25rem;
}

.result-tag {
    background-color: var(--pst-color-surface);
    color: var(--pst-color-text-base);
    border: 1px solid var(--pst-color-on-surface);
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    display: inline-block;
    margin-right: 0.5rem;
    margin-bottom: 0.25rem;
}

.result-category {
    background-color: rgba(118, 185, 0, 0.1);
    color: var(--nv-color-green);
    border: 1px solid rgba(118, 185, 0, 0.2);
}

.multiple-matches-indicator {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--nv-color-green);
    background-color: rgba(118, 185, 0, 0.1);
    border-radius: 0.25rem;
    border: 1px solid rgba(118, 185, 0, 0.2);
    margin-left: 0.5rem;
}

.more-tags, .more-categories {
    font-size: 0.75rem;
    color: var(--pst-color-text-muted);
    font-style: italic;
    margin-left: 0.25rem;
}

.result-tags, .result-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    align-items: center;
}

/* Badge styles */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.25rem;
    text-decoration: none;
}

.bg-secondary {
    background-color: var(--pst-color-text-muted) !important;
    color: var(--pst-color-background) !important;
}

.bg-info {
    background-color: rgba(118, 185, 0, 0.9) !important;
    color: var(--pst-color-background) !important;
}

.bg-light {
    background-color: transparent !important;
    color: var(--pst-color-text-muted) !important;
    border: 1px solid var(--pst-color-on-surface) !important;
}

/* Metadata badges */
.metadata-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    margin-right: 0.5rem;
    margin-bottom: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.375rem;
    border: 1px solid;
    cursor: help;
    transition: all 0.2s ease;
}

.persona-badge {
    background-color: #e8f5e8;
    color: #2d5a2d;
    border-color: #c3e6c3;
}

.difficulty-badge {
    background-color: #fff3cd;
    color: #856404;
    border-color: #ffeaa7;
}

.modality-badge {
    background-color: #e2f3ff;
    color: #0c5460;
    border-color: #b8daff;
}

.metadata-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Clickable badge styles */
.clickable-badge {
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.clickable-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    filter: brightness(1.1);
}

.clickable-badge:active {
    transform: translateY(0);
}

.result-tag.clickable-badge:hover {
    background-color: var(--nv-color-green);
    color: var(--pst-color-background);
    border-color: var(--nv-color-green);
}

/* Active filter display */
.active-filters-display {
    background-color: var(--pst-color-surface);
    border: 1px solid var(--pst-color-on-surface);
    border-radius: 0.375rem;
    padding: 0.75rem;
}

.active-filter-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.5rem;
    margin-right: 0.5rem;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 0.25rem;
    background-color: var(--nv-color-green);
    color: var(--pst-color-background);
    border: 1px solid var(--nv-color-green);
}

/* Utility classes for layout */
.mb-1 { margin-bottom: 0.25rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.mb-4 { margin-bottom: 1.5rem !important; }
.mt-1 { margin-top: 0.25rem !important; }
.mt-3 { margin-top: 1rem !important; }
.me-1 { margin-right: 0.25rem !important; }
.me-2 { margin-right: 0.5rem !important; }
.me-3 { margin-right: 1rem !important; }
.ms-2 { margin-left: 0.5rem !important; }
.ms-4 { margin-left: 1.5rem !important; }

.d-flex { display: flex !important; }
.align-items-center { align-items: center !important; }
.align-items-start { align-items: flex-start !important; }
.flex-grow-1 { flex-grow: 1 !important; }
.flex-wrap { flex-wrap: wrap !important; }
.gap-2 { gap: 0.5rem !important; }

.text-decoration-none { text-decoration: none !important; }
.text-center { text-align: center !important; }
.text-muted { color: var(--pst-color-text-muted) !important; }

.py-4 { padding-top: 1.5rem !important; padding-bottom: 1.5rem !important; }
.p-2 { padding: 0.5rem !important; }

.border { border: 1px solid var(--pst-color-on-surface) !important; }
.rounded { border-radius: 0.25rem !important; }

.small { font-size: 0.875rem !important; }

/* Empty and Error States */
.no-results {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--pst-color-text-muted);
    font-family: var(--pst-font-family-base);
}

.no-results h3 {
    color: var(--pst-color-heading);
    font-family: var(--pst-font-family-heading);
    font-weight: var(--pst-font-weight-heading);
    font-size: var(--pst-font-size-h3);
    margin: 0 0 1rem 0;
}

.no-results p {
    font-size: 1.125rem;
    line-height: 1.6;
    margin: 0;
}

.error-message {
    background-color: var(--pst-color-surface);
    border: 1px solid var(--pst-color-on-surface);
    border-left: 4px solid var(--nv-color-green);
    border-radius: 0.5rem;
    padding: 1rem;
    margin: 1rem 0;
    color: var(--pst-color-text-base);
    font-family: var(--pst-font-family-base);
}

/* Search Highlighting */
.search-highlight,
mark {
    background-color: rgba(118, 185, 0, 0.2);
    color: var(--pst-color-text-base);
    padding: 0.0625rem 0.125rem;
    border-radius: 0.125rem;
    font-weight: 400;
    border: 1px solid rgba(118, 185, 0, 0.3);
}

/* Section-specific icon colors and styles */
.section-badge.getting-started {
    background: linear-gradient(135deg, var(--nv-color-green), var(--nv-color-green-2));
    color: var(--pst-color-background);
    border-color: var(--nv-color-green);
}

.section-badge.admin {
    background-color: var(--pst-color-surface);
    color: var(--pst-color-text-base);
}

.section-badge.reference {
    background-color: var(--pst-color-surface);
    color: var(--pst-color-text-base);
}

.section-badge.tutorial {
    background-color: var(--pst-color-surface);
    color: var(--pst-color-text-base);
}

/* Empty state icons and messaging */
.search-empty-state,
.search-no-results {
    text-align: center;
    padding: 2rem;
    color: var(--pst-color-text-muted);
    font-family: var(--pst-font-family-base);
}

.search-empty-state i,
.search-no-results i {
    font-size: 3rem;
    color: var(--pst-color-text-muted);
    margin-bottom: 1rem;
    display: block;
}

.search-empty-state h4,
.search-no-results h4 {
    color: var(--pst-color-heading);
    font-family: var(--pst-font-family-heading);
    font-size: var(--pst-font-size-h4);
    margin-bottom: 0.5rem;
}

.search-empty-state p,
.search-no-results p {
    color: var(--pst-color-text-muted);
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .search-result {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .result-header {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .section-icon {
        width: 2.5rem;
        height: 2.5rem;
        font-size: 1rem;
    }
    
    .result-title {
        font-size: var(--pst-font-size-h5);
    }
    
    .result-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .section-links {
        padding: 0.5rem;
    }
    
    .section-link {
        padding: 0.375rem 0.5rem;
        font-size: 0.8125rem;
    }
    
    #enhanced-search-page-input {
        font-size: 1rem;
        padding: 0.875rem 1rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .search-result {
        border-width: 2px;
    }
    
    .search-result:hover {
        border-width: 3px;
    }
    
    .search-highlight,
    mark {
        outline: 1px solid var(--pst-color-text-base);
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .search-result,
    .section-link,
    #enhanced-search-page-input,
    .search-result::before {
        transition: none;
    }
    
    .spinner {
        animation: none;
    }
}

/* Print styles */
@media print {
    .search-result {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid;
        margin-bottom: 1rem;
        background: transparent !important;
    }
    
    .section-icon {
        background: transparent !important;
        border: 1px solid;
    }
    
    .section-link {
        text-decoration: underline !important;
    }
    
    .search-highlight,
    mark {
        background: transparent !important;
        text-decoration: underline;
        font-weight: bold;
    }
}

/* Focus states for accessibility */
#enhanced-search-page-input:focus-visible {
    outline: 2px solid var(--nv-color-green);
    outline-offset: 2px;
}

.section-link:focus-visible {
    outline: 2px solid var(--nv-color-green);
    outline-offset: 2px;
}

.result-title a:focus-visible {
    outline: 2px solid var(--nv-color-green);
    outline-offset: 2px;
    border-radius: 0.125rem;
}

/* Dark theme support */
html[data-theme="dark"] .search-result {
    background: var(--pst-color-surface-200, #1f2937);
}

html[data-theme="dark"] .search-result:hover {
    background: var(--pst-color-surface-300, #111827);
}

html[data-theme="dark"] .search-results-header h3 {
    color: var(--pst-color-text-base, #f9fafb);
}

/* Accessibility enhancements */
@media (prefers-reduced-motion: reduce) {
    .search-result,
    .section-link,
    #enhanced-search-page-input {
        transition: none;
    }
}

@media (prefers-contrast: high) {
    .search-result {
        border-color: var(--pst-color-text-base);
    }
    
    .search-highlight,
    mark {
        background: var(--nv-color-green);
        color: var(--pst-color-background);
    }
}

/* AI Assistant container styling */
.ai-assistant-container {
    border: 1px solid var(--pst-color-border);
    border-radius: var(--pst-border-radius);
    background: var(--pst-color-surface);
    padding: 1rem;
    margin-top: 1.5rem;
}

.ai-assistant-container .ai-loading {
    text-align: center;
    padding: 2rem;
    color: var(--pst-color-text-muted);
}

.ai-assistant-container .ai-response {
    line-height: 1.6;
}

.ai-assistant-container .ai-error {
    color: var(--pst-color-danger);
    background: var(--pst-color-danger-bg);
    padding: 1rem;
    border-radius: var(--pst-border-radius);
    border-left: 4px solid var(--pst-color-danger);
}

/* AI Assistant dark theme support */
html[data-theme="dark"] .ai-assistant-container {
    background: var(--pst-color-surface-200, #1f2937);
    border-color: var(--pst-color-border-dark, #374151);
}

 